<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="lijun; 67086071; zwlijun@qq.com" />
<title>RIA Client API - BY 小网</title>
<link href="css/api.css" type="text/css" rel="stylesheet" />
</head>

<body>
  <ins>此文档描述String对象的扩展</ins>
  <div class="nav">
    <a href="#startsWith">startsWith()</a>
    <a href="#endsWith">endsWith()</a>
    <a href="#replaceAll">replaceAll()</a>
    <a href="#replaceFirst">replaceFirst()</a>
    <a href="#trim">trim()</a>
    <a href="#leftTrim">leftTrim()</a>
    <a href="#rightTrim">rightTrim()</a>
    <a href="#bothTrim">bothTrim()</a>
    <a href="#size">size()</a>
  </div>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">startsWith方法<a name="startsWith"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>匹配以prefix开头的字符串</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.startsWith(prefix, offset)</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>匹配以prefix开头的字符串</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "this is my first javascript program!";
var isMatch = str.startsWith("this");
isMatch = str.startsWith("this", 5);
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">endsWith方法<a name="endsWith"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>匹配以suffix结尾的字符串</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.endsWith(suffix)</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>匹配以suffix结尾的字符串</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "this is my first javascript program!";
var isMatch = str.endsWith("program!");
isMatch = str.endsWith("program");
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">replaceAll方法<a name="replaceAll"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>替换所有相匹配的字符或字符串</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.replaceAll(regexp, replacement)</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>替换所有相匹配的字符或字符串</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "this is a test string, 
           this is my first javascript program!";
var newString = str.replaceAll("this", "that");
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">replaceFirst方法<a name="replaceFirst"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>替换匹配表达式第一次出现的内容</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.replaceFirst(regexp, replacement)</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>替换匹配表达式第一次出现的内容</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "this is a test string, 
           this is my first javascript program!";
var newString = str.replaceFirst("this", "that");
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">trim方法<a name="trim"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>去空字符</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.trim()</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>去空字符</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "  this is a test string, 
           this is my first javascript program!  ";
var newString = str.trim();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">leftTrim方法<a name="leftTrim"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>去左空字符</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.leftTrim()</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>去左空字符</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "  this is a test string, 
           this is my first javascript program!  ";
var newString = str.leftTrim();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">rightTrim方法<a name="rightTrim"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>去右空字符</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.rightTrim()</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>去右空字符</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "  this is a test string, 
           this is my first javascript program!  ";
var newString = str.rightTrim();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">bothTrim方法<a name="bothTrim"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>去两边空字符</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.bothTrim()</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>去两边空字符</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "  this is a test string, 
           this is my first javascript program!  ";
var newString = str.bothTrim();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
  <table width="600" cellspacing="1" cellpadding="1" border="0">
    <tbody>
      <tr>
        <th colspan="2">size方法<a name="size"></a></th>
      </tr>
      <tr>
        <td class="label">作&nbsp;&nbsp;&nbsp;用</td>
        <td>返回实际长度,区分中英文</td>
      </tr>
      <tr>
        <td class="label">基本语法</td>
        <td>str.size()</td>
      </tr>
      <tr>
        <td class="label">说&nbsp;&nbsp;&nbsp;明</td>
        <td>返回实际长度,区分中英文</td>
      </tr>
      <tr>
        <td class="label">示&nbsp;&nbsp;&nbsp;例</td>
        <td>
<pre>
var str = "  this is a test string, 
           this is my first javascript program!  ";
var len = str.size();
</pre>
        </td>
      </tr>
    </tbody>
  </table>
</body>
</html>